#ifndef SIMUBOARD_FANWIDGET_HPP
#define SIMUBOARD_FANWIDGET_HPP

#include <FL/Fl_Gl_Window.H>

class Fl_SVG_Image;

class FanWidget : public Fl_Gl_Window
{
public:
    FanWidget(int X, int Y, int W, int H, const char* label = nullptr);
    ~FanWidget() override;
    void set_level(int lvl);
    int level() const { return level_; }
    void advance();

protected:
    void draw() override; // OpenGL 绘制
private:
    static Fl_SVG_Image* s_fan_svg;
    static void ensure_loaded();
    int level_ = 0;
    double angle_deg_ = 0.0;

    unsigned int tex_id_ = 0;
    int tex_w_ = 0;
    int tex_h_ = 0;
    bool texture_ready_ = false;

    void build_texture(int desired);
};

#endif // SIMUBOARD_FANWIDGET_HPP
